package com.shengchang.hu.supervision.UI;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

/**
 * Created by Administrator on 2018/8/14 0014.
 */

public class BaseActivity extends AppCompatActivity {

    private ProgressDialog mProgressDialog;

    public void dismissProgressDialog()
    {
        if ((this.mProgressDialog != null) && (this.mProgressDialog.isShowing())) {
            this.mProgressDialog.cancel();
        }
    }

    public void showLongToast(String paramString)
    {
        if (!isFinishing()) {
            Toast.makeText(this, paramString, Toast.LENGTH_LONG).show();
        }
    }

    public void showProgressDialog()
    {
        showProgressDialog("", "加载中...", true);
    }

    public void showProgressDialog(String paramString1, String paramString2, boolean paramBoolean)
    {
        if (this.mProgressDialog == null) {
            this.mProgressDialog = new ProgressDialog(this);
        }
        this.mProgressDialog.setTitle(paramString1);
        this.mProgressDialog.setCancelable(paramBoolean);
        this.mProgressDialog.setMessage(paramString2);
        if (!isFinishing()) {
            this.mProgressDialog.show();
        }
    }

    public void showShortToast(String paramString)
    {
        if (!isFinishing()) {
            Toast.makeText(this, paramString, Toast.LENGTH_SHORT).show();
        }
    }

    public void showTipDialog(String paramString)
    {
        showTipDialog(paramString, null);
    }

    public void showTipDialog(String paramString, DialogInterface.OnClickListener paramOnClickListener)
    {
        showTipDialog(paramString, true, paramOnClickListener);
    }

    public void showTipDialog(String paramString, boolean paramBoolean, DialogInterface.OnClickListener paramOnClickListener)
    {
        AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
        localBuilder.setTitle("提示");
        localBuilder.setMessage(paramString);
        localBuilder.setCancelable(paramBoolean);
        localBuilder.setPositiveButton("确定", paramOnClickListener);
        localBuilder.create().show();
    }
}
